<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="/authUtil"  prefix="authUtil"%>
<%@taglib uri="/adminUtil"  prefix="adminUtil"%>
<!doctype html>
<html lang="ch">

    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="description" content="左右结构项目，属于大人员的社交工具">
        <meta name="keywords" content="左右结构项目 社交 占座 ">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <meta name="format-detection" content="telephone=no">
        <title>宾馆管理系统</title>
        <script src="/hotel/js/jquery.min.js"></script>
        <script src="js/bootstrap.min.js"></script>
        <link href="css/bootstrap.min.css" rel="stylesheet">
        <link rel="stylesheet" type="text/css" href="css/common.css" />
        <link rel="stylesheet" type="text/css" href="css/flat-ui.min.css" />
    </head>

    <body>
        <div id="wrap">
            <!-- 左侧菜单栏目块 -->
            <div class="leftMeun" id="leftMeun">
                <div id="logoDiv">
                    <p id="logoP"><img id="logo" alt="左右结构项目" src="images/logo.png"><span>宾馆管理系统</span></p>
                </div>
                <div id="personInfor">
                    <p id="userName">${user.name }</p>
                    <p><span>身份：</span>${adminUtil:getAdminRole(user.roleCode) } </p>
                    <p>
                        <a href="/hotel/system/loginPage">退出登录</a>
                    </p>
                </div>
                <div class="meun-title">人力管理</div>
                <c:if test="${authUtil:isAuth(user.auth,0) }">
					<div id='auth0' onclick='funAuth(0)' class="meun-item meun-item-active" aria-controls="sour" role="tab" data-toggle="tab">
						<img src="images/icon_source.png">人力管理菜单
					</div>
				</c:if>
				<div class="meun-title">房间管理</div>
                <c:if test="${authUtil:isAuth(user.auth,1) }">
					<div id='auth1' onclick='funAuth(1)' class="meun-item" aria-controls="char" role="tab" data-toggle="tab">
						<img src="images/icon_chara_grey.png">房型管理菜单
					</div>
				</c:if>
				<c:if test="${authUtil:isAuth(user.auth,2) }">
					<div id='auth2' onclick='funAuth(2)' class="meun-item" aria-controls="char" role="tab" data-toggle="tab">
						<img src="images/icon_chara_grey.png">房间管理菜单
					</div>
				</c:if>
					<div class="meun-title">前台管理</div>
				<c:if test="${authUtil:isAuth(user.auth,3) }">
					<div id='auth3' onclick='funAuth(3)' class="meun-item" aria-controls="char" role="tab" data-toggle="tab">
						<img src="images/icon_chara_grey.png">入住信息列表
					</div>
					<div id='auth9' onclick='funAuth(9)' class="meun-item" aria-controls="char" role="tab" data-toggle="tab">
						<img src="images/icon_chara_grey.png">新建线下入住
					</div>
					<div id='auth10' onclick='funAuth(10)' class="meun-item" aria-controls="char" role="tab" data-toggle="tab">
						<img src="images/icon_chara_grey.png">新建线上入住
					</div>
					<div id='auth11' onclick='funAuth(11)' class="meun-item" aria-controls="char" role="tab" data-toggle="tab">
						<img src="images/icon_chara_grey.png">查看订单列表
					</div>
				</c:if>
				<!-- 
				<c:if test="${authUtil:isAuth(user.auth,4) }">
					<div id="auth4" class="meun-item" aria-controls="char" role="tab" data-toggle="tab">
						<img src="images/icon_chara_grey.png">换房管理菜单
					</div>
				</c:if>
				<c:if test="${authUtil:isAuth(user.auth,5) }">
					<div id="auth5" class="meun-item" aria-controls="char" role="tab" data-toggle="tab">
						<img src="images/icon_chara_grey.png">续住管理菜单
					</div>
				</c:if>
				 -->
					<div class="meun-title">财务管理</div>
				<c:if test="${authUtil:isAuth(user.auth,6) }">
					<div id='auth6' onclick='funAuth(6)' class="meun-item" aria-controls="char" role="tab" data-toggle="tab">
						<img src="images/icon_chara_grey.png">收支情况列表
					</div>
					<div id='auth7' onclick='funAuth(7)' class="meun-item" aria-controls="char" role="tab" data-toggle="tab">
						<img src="images/icon_chara_grey.png">房型价格菜单
					</div>
					<div id='auth8' onclick='funAuth(8)' class="meun-item" aria-controls="char" role="tab" data-toggle="tab">
						<img src="images/icon_chara_grey.png">房间价格菜单
					</div>
				</c:if>
            </div>
            <!-- 右侧具体内容栏目 -->
            <div id="rightContent">
                    
			</div>
        </div> 
    </body>         
<script type="text/javascript" src="/hotel/js/cookiesUtil.js"></script>   
<script>
	function light(obj){
		$(".meun-item").removeClass("meun-item-active");
		obj.addClass("meun-item-active");
		var itmeObj = $(".meun-item").find("img");
        itmeObj.each(function() {
             var items = obj.attr("src");
             items = items.replace("_grey.png", ".png");
             items = items.replace(".png", "_grey.png")
             obj.attr("src", items);
        });
        var attrObj = obj.find("img").attr("src");
        ;
        attrObj = attrObj.replace("_grey.png", ".png");
        obj.find("img").attr("src", attrObj);
	}
	$(".meun-item").click(function() {
		//选单条框动画
		light($(this))
    });
	//按钮区域
	function funAuth(authCode){
		fun=authCode
		switch(authCode){
		case 0:
			$("#rightContent").load( "/hotel/admin/mainMenu")
			break;
		case 1:
			$("#rightContent").load( "/hotel/roomType/roomTypeList")
			break;
		case 2:
			$("#rightContent").load( "/hotel/room/roomList")
			break;
		case 3:
			$("#rightContent").load( "/hotel/checkIn/checkInList")
			break;
		case 6:
			$("#rightContent").load( "/hotel/finance/exchangePage")
			break;
		case 7:
			$("#rightContent").load( "/hotel/finance/typePricePage")
			break;
		case 8:
			$("#rightContent").load( "/hotel/finance/roomPricePage")
			break;
		case 9:
			$("#rightContent").load( "/hotel/checkIn/offLineCheckInMenu")
			break;
		case 10:
			$("#rightContent").load( "/hotel/checkIn/onLineCheckInMenu")
			break;
		case 11:
			$("#rightContent").load( "/hotel/reserve/getReserves")
			break;
		}
		setCookie("fun",fun);
	}
	//加载对应菜单
	var fun=getCookie('fun');	//从cookies中拿到功能
	//如果fun不为空，如其保存的选项与管理员所拥有的权限相同，则载入对应页面
	//如果fun为空，则载入对应角色的菜单页面
	if(fun==null){	//如果fun为空
		alert('test')
		<c:if test="${user.roleCode==0}">
			$("#rightContent").load( "/hotel/admin/mainMenu")
			fun=0;
			setCookie("fun",fun);
		</c:if>
		<c:if test="${user.roleCode==1}">
			$("#rightContent").load( "/hotel/roomType/roomTypeList")
			fun=1;
			setCookie("fun",fun);
		</c:if>
		<c:if test="${user.roleCode==2}">
			$("#rightContent").load( "/hotel/checkIn/checkInList")
			fun=3;
			setCookie("fun",fun);
		</c:if>
		<c:if test="${user.roleCode==3}">
			$("#rightContent").load( "/hotel/finance/mainMenu")
			fun=6;
			setCookie("fun",fun);
		</c:if>
	}else{	//如果fun不为空
		switch(eval(fun)){
		case 0:
			//alert('in')
			$("#rightContent").load("/hotel/admin/mainMenu")
			break;
		case 1:
			$("#rightContent").load( "/hotel/roomType/roomTypeList")
			break;
		case 2:
			$("#rightContent").load( "/hotel/room/roomList")
			break;
		case 3:
		case 9:
		case 10:
			
			$("#rightContent").load( "/hotel/checkIn/checkInList")
			break;
		case 6:
			$("#rightContent").load( "/hotel/finance/exchangePage")
			break;
		case 7:
			$("#rightContent").load( "/hotel/finance/typePricePage")
			break;
		case 8:
			$("#rightContent").load( "/hotel/finance/roomPricePage")
			break;
		case 11:
			$("#rightContent").load( "/hotel/reserve/getReserves")
			break;
		}
		if(fun<9||fun>10)
			light($('#auth'+fun))
		else
			light($('#auth3'))
	}
</script>


</html>